package com.ruoyi.app.config;

import com.ruoyi.app.interceptor.ApiLocalinterceptor;
import com.ruoyi.app.interceptor.VersionLocalinterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
 * 通用配置
 * 
 * @author ruoyi
 */
@Configuration
public class ResourcesConfig implements WebMvcConfigurer
{
    @Autowired
    private VersionLocalinterceptor versionLocalinterceptor;
    @Autowired
    private ApiLocalinterceptor apiLocalinterceptor;

    /**
     * 自定义拦截规则
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry)   {
        //配置 不需要拦截的包和请求
        String[] excludeVersionPathPatterns = new String[]{
                VersionLocalinterceptor.version+ "/api/common/**",
                VersionLocalinterceptor.version+ "/common/**",
                "/v3/api-docs/**",
                "/doc.html",
                "/swagger-resources/**",
                "/webjars/**",
                "/openIMApi/user_token",
                VersionLocalinterceptor.version+ "/openIMApi/user_token",
                VersionLocalinterceptor.version+   "/auth/im-user/reloadPass",
                VersionLocalinterceptor.version+   "/auth/imUser/reg",
                VersionLocalinterceptor.version+   "/auth/imUser/login",
                VersionLocalinterceptor.version+   "/auth/sysConfig/**",
                VersionLocalinterceptor.version+   "/auth/sysContentOption/**",
        };
        //配置 不需要拦截的包和请求
        String[] apiExcludePathPatterns = new String[]{
                VersionLocalinterceptor.version+ "/api/common/**",
                VersionLocalinterceptor.version+ "/common/**",
                "/v3/api-docs/**",
                   "/doc.html",
                  "/swagger-resources/**",
                  "/webjars/**",
                  "/openIMApi/user_token",
                VersionLocalinterceptor.version+   "/auth/im-user/reloadPass",
                VersionLocalinterceptor.version+   "/auth/imUser/reg",
                VersionLocalinterceptor.version+   "/auth/imUser/login",
                VersionLocalinterceptor.version+   "/auth/sysConfig/**",
                VersionLocalinterceptor.version+   "/auth/sysContentOption/**",

        };
        registry.addInterceptor(versionLocalinterceptor).addPathPatterns("/**").excludePathPatterns(excludeVersionPathPatterns);
        registry.addInterceptor(apiLocalinterceptor).addPathPatterns("/**").excludePathPatterns(apiExcludePathPatterns);
    }


}